package thread.synchronize_dirty_data;

/**
 * Created by mHandler on 2018/5/29 0029.
 * Description:
 */
public class PublicVar  {

    public String username= "a";
    public String password = "aa";
    synchronized public void setValue(String username,String password){
        try {
            this.username = username;
            Thread.sleep(2000);
            this.password = password;
            System.out.println("setval"+Thread.currentThread().getName()+ "username = "+username+ " password="+password);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    synchronized public void getValue(){
        System.out.println("getval"+Thread.currentThread().getName()+ "username = "+username+ " password="+password);
    }
}
